import React, { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
import { getQuestionInfo } from "../services/question";
import { useRequest } from "ahooks";

// 自定义hooks就是个函数
// 获取单个问卷详情信息
const useLoadQuestionData = () => {
  const { id = '' } = useParams()
  useEffect(() => {
  }, [])
  const fetchInfo = async () => {
    return await getQuestionInfo(id)
  }
  const { loading, data: questionData } = useRequest(fetchInfo) // 利用useRequest 发请求   页面初始化就会触发
  return {
    loading, questionData
  }
}

export default useLoadQuestionData